package com.aaa.market.controller;


import com.aaa.market.pojo.entity.Position;
import com.aaa.market.pojo.vo.PositionVo;
import com.aaa.market.service.PositionService;
import com.gsj.common.pojo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: clms-eighth
 * @description:
 * @author: 刘守霖
 * @create: 2021-07-25 14:55
 **/
@RestController
@RequestMapping("/market/position")
@Api(description = "广告位置")
public class PositionController {
    @Autowired
    private PositionService positionService;

    @PostMapping("/initPositionTable/{currentPage}/{pageSize}")
    @ApiOperation(value = "查询广告位置表",httpMethod="POST")
    @ApiImplicitParams( {
            @ApiImplicitParam(name = "currentPage",value = "第几页"),@ApiImplicitParam(name = "pageSize",value = "分页数"),
            @ApiImplicitParam(name = "positionVo",value = "查询条件")
    })
    public R initPositionTable(@PathVariable("currentPage")Integer currentPage,
                               @PathVariable("pageSize")Integer pageSize,
                               @RequestBody PositionVo positionVo) {
        return positionService.findPositionByPage(currentPage, pageSize, positionVo);
    }
    //新增
    @PostMapping("addbyPositonId")
    @ApiOperation(value = "新增广告位置表数据",httpMethod="POST")

    public R addbyPositonId(@RequestBody Position position){
        return positionService.insertPosition(position);
    }
    //修改
    @PostMapping("changePosition")
    @ApiOperation(value = "修改广告位置表中数据",httpMethod="POST")
    public R changePosition(@RequestBody Position position){
        return positionService.changePosition(position);
    }
    //删除
    @DeleteMapping("delPosition")
    @ApiOperation(value = "根据id删除广告位置表中数据",httpMethod="DELETE")
    @ApiImplicitParam(name = "id",value = "广告位置id")
    public R delPosition(Integer id){
        return positionService.delPosition(id);
    }
    @GetMapping("chaXun")
    @ApiOperation(value = "修改前将数据回显到表单",httpMethod="GET")
    public R chaXun(Integer id){
        return positionService.chaXun(id);
    }

    @GetMapping("queryPosition")
    public R queryPosition(){
        return positionService.queryPosition();
    }
}
